﻿using System;
using System.Diagnostics.CodeAnalysis;

namespace ChessKit.Properties
{
  /// <summary>
  /// When applied to a target attribute, specifies a requirement for any Type marked with 
  /// the target attribute to implement or inherit specific Type or types.
  /// </summary>
  /// <example>
  /// <code>
  /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
  /// [UsedImplicitly(ImplicitUseTargetFlags.WithMembers)] internal class ComponentAttribute : Attribute 
  /// {}
  /// 
  /// [Component] // ComponentAttribute requires implementing IComponent interface
  /// [UsedImplicitly(ImplicitUseTargetFlags.WithMembers)] internal class MyComponent : IComponent
  /// {}
  /// </code>
  /// </example>
  [SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments", 
    Justification = "Jetbrains thinks in's right"), 
  AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
  [BaseTypeRequired(typeof(Attribute))]
	[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
  sealed class BaseTypeRequiredAttribute : Attribute
  {
    /// <summary>
    /// Initializes new instance of BaseTypeRequiredAttribute
    /// </summary>
    /// <param name="baseType">Specifies which types are required</param>
    public BaseTypeRequiredAttribute(Type baseType)
    {
      BaseTypes = new[] { baseType };
    }

    /// <summary>
    /// Gets enumerations of specified base types
    /// </summary>
    [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays",
    Justification = "Jetbrains thinks in's right") ]
    public Type[] BaseTypes { get; private set; }
  }
}